import { addNameSpace } from './util'

const NAME_SPACE = 'LAYOUT'

const addPrefix = addNameSpace(NAME_SPACE)

// 登出
export const LOGOUT = addPrefix('LOGOUT')

// 登出成功
export const LOGOUT_SUCCESS = addPrefix('LOGOUT_SUCCESS')

// 获取数据
export const GET_USER_INFO = addPrefix('GET_USER_INFO')

// 获取数据成功
export const GET_USER_INFO_SUCCESS = addPrefix('GET_USER_INFO_SUCCESS')

// 获取数据失败
export const GET_USER_INFO_FAIL = addPrefix('GET_USER_INFO_FAIL')

export const logout = () => ({ type: LOGOUT })

export const logoutSuccess = () => ({ type: LOGOUT_SUCCESS })

export const getUserInfo = () => ({ type: GET_USER_INFO })

export const getUserInfoSuccess = (data) => ({ type: GET_USER_INFO_SUCCESS, data })

export const getUserInfoFail = () => ({ type: GET_USER_INFO_FAIL })

export default {
  logout,
  logoutSuccess,
  getUserInfo,
  getUserInfoSuccess,
  getUserInfoFail,
}